package com.muyu.system.service.impl;


import com.muyu.common.core.utils.DateUtils;
import com.muyu.system.domain.DanmoVipPerson;
import com.muyu.system.domain.DanmoVipRights;
import com.muyu.system.mapper.DanmoVipPersonMapper;
import com.muyu.system.mapper.DanmoVipRightsMapper;
import com.muyu.system.service.IDanmoVipRightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * vip权益Service业务层处理
 * 
 * @author yl
 * @date 2025-06-10
 */
@Service
public class DanmoVipRightsServiceImpl implements IDanmoVipRightsService
{
    @Autowired
    private DanmoVipRightsMapper danmoVipRightsMapper;

    /**
     * 查询vip权益
     * 
     * @param id vip权益主键
     * @return vip权益
     */
    @Override
    public DanmoVipRights selectDanmoVipRightsById(Long id)
    {
        return danmoVipRightsMapper.selectDanmoVipRightsById(id);
    }

    /**
     * 查询vip权益列表
     * 
     * @param danmoVipRights vip权益
     * @return vip权益
     */
    @Override
    public List<DanmoVipRights> selectDanmoVipRightsList(DanmoVipRights danmoVipRights)
    {
        return danmoVipRightsMapper.selectDanmoVipRightsList(danmoVipRights);
    }

    /**
     * 新增vip权益
     * 
     * @param danmoVipRights vip权益
     * @return 结果
     */
    @Override
    public int insertDanmoVipRights(DanmoVipRights danmoVipRights)
    {
        danmoVipRights.setCreateTime(DateUtils.getNowDate());
        return danmoVipRightsMapper.insertDanmoVipRights(danmoVipRights);
    }

    /**
     * 修改vip权益
     * 
     * @param danmoVipRights vip权益
     * @return 结果
     */
    @Override
    public int updateDanmoVipRights(DanmoVipRights danmoVipRights)
    {
        danmoVipRights.setUpdateTime(DateUtils.getNowDate());
        return danmoVipRightsMapper.updateDanmoVipRights(danmoVipRights);
    }

    /**
     * 批量删除vip权益
     * 
     * @param ids 需要删除的vip权益主键
     * @return 结果
     */
    @Override
    public int deleteDanmoVipRightsByIds(Long[] ids)
    {
        return danmoVipRightsMapper.deleteDanmoVipRightsByIds(ids);
    }

    /**
     * 删除vip权益信息
     * 
     * @param id vip权益主键
     * @return 结果
     */
    @Override
    public int deleteDanmoVipRightsById(Long id)
    {
        return danmoVipRightsMapper.deleteDanmoVipRightsById(id);
    }

    @Autowired
    private DanmoVipPersonMapper danmoVipPersonMapper;
    @Override
    public List<DanmoVipRights> getPersonRights(Long userid) {
        DanmoVipPerson danmoVipPerson = new DanmoVipPerson();
        danmoVipPerson.setUserId(userid);
        DanmoVipPerson danmoVipPerson1 = danmoVipPersonMapper.selectDanmoVipPerson(danmoVipPerson);
        Long vipInfoId = danmoVipPerson1.getVipInfoId();
        DanmoVipRights danmoVipRights = new DanmoVipRights();

        if (vipInfoId != null) {
            danmoVipRights.setVipInfoId(vipInfoId);
        }
        List<DanmoVipRights> danmoVipRightsList = danmoVipRightsMapper.selectDanmoVipRightsList(danmoVipRights);
        return danmoVipRightsList;

    }
}
